package javamusic.Servlet.Cliente;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;


import javamusic.modelo.ReservaCliente;
import javamusic.negocio.GestionReservaCliente;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ServletClienteReserva
 */
@WebServlet("/ServletClienteReserva")
public class ServletClienteReserva extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletClienteReserva() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		GestionReservaCliente negocio = new GestionReservaCliente();
		
		
		try {
			Collection<ReservaCliente> listado = negocio.listar();
			
			for (ReservaCliente lista : listado) {
				
				lista.getNombre();
				System.out.println("prueba-- " + lista.getNombre());
				
			}
			request.setAttribute("LOCALES_REGISTRADOS", listado);
			RequestDispatcher rd = request.getRequestDispatcher("FromReservaCliente.jsp");
			
			
			rd.forward(request, response);
			//request.setAttribute("LOCALES_REGISTRADOS", listado);
			
			
		} catch (javamusic.excepcion.DAOExcepcion e) {
			System.out.println(e.getMessage());
			//RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
					}
						
	
		
		
		
		
	}
	

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
GestionReservaCliente negocio = new GestionReservaCliente();
		
		
		try {
			Collection<ReservaCliente> listado = negocio.listar();
			
			for (ReservaCliente lista : listado) {
				
				lista.getNombre();
								
				System.out.println(lista.getNombre());
			}
			RequestDispatcher rd = request.getRequestDispatcher("/FormReservaCliente.jsp");
			request.setAttribute("LOCALES_REGISTRADOS", listado);
			
			rd.forward(request, response);
			
		} catch (javamusic.excepcion.DAOExcepcion e) {
			System.out.println(e.getMessage());
			//RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
					}
	}
}
